package com.stars.services.impl.mygenerate;/**
 * Created by luodajie on 2019/1/6.
 */

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.stars.dao.mapper.mygenerate.CgFormFieldMapper;
import com.stars.entity.ListPage;
import com.stars.entity.mygenerate.CgFormField;
import com.stars.services.impl.BaseAccessServiceImpl;
import com.stars.services.mygenerate.CgFormFieldServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :dj
 * @version : 1.0.0
 * @description
 * @Date 2019-01-06 11:25
 * @note
 */
@Service
public class CgFormFieldServicesImpl extends BaseAccessServiceImpl<CgFormFieldMapper, CgFormField> implements
        CgFormFieldServices {
    @Autowired
    private CgFormFieldMapper cgFormFieldMapper;

    @Override
    public PageInfo<CgFormField> pageQuery(Integer pageNum, Integer pageSize, CgFormField cgFormHead) throws Exception {
        ListPage<CgFormField> listPage = new ListPage<>(pageNum, pageSize, cgFormHead);
        PageHelper.startPage(pageNum, pageSize);
        List<CgFormField> blogList = cgFormFieldMapper.pageQuery(listPage);
        PageInfo<CgFormField> pageInfo = new PageInfo<>(blogList);
        return pageInfo;
    }

    @Override
    public void add(CgFormField cgFormField) {
        cgFormFieldMapper.insert(cgFormField);
    }

    @Override
    public void update(CgFormField cgFormField) {
        cgFormFieldMapper.updateByPrimaryKey(cgFormField);
    }

    @Override
    public void delById(String id) {
        CgFormField cgFormField = cgFormFieldMapper.selectByPrimaryKey(id);
        cgFormFieldMapper.delete(cgFormField);
    }

    @Override
    public CgFormField findById(String id) {
        return cgFormFieldMapper.selectByPrimaryKey(id);
    }
}
